package com.souku.finance.application.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.souku.finance.application.R;
import com.souku.finance.application.bean.RequestHasBean;
import com.souku.finance.application.utils.MyTextUtil;

import java.util.List;

/**
 * Created by Android on 2016/12/20.
 */

public class AlreadyRequestAdapter extends BaseAdapter {

    private List<RequestHasBean.ListBean> listhas;

    public AlreadyRequestAdapter(List<RequestHasBean.ListBean> listhas) {
        this.listhas = listhas;
    }

    @Override
    public int getCount() {
        return listhas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder = null;
        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alreadyrequest, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        RequestHasBean.ListBean bean=listhas.get(position);
        viewHolder.tvName.setText(bean.getRealName());
        viewHolder.tvMoney.setText(MyTextUtil.setMoneyToElement(bean.getInvestMoney())+"元");
        viewHolder.tvRebateMoney.setText(MyTextUtil.setMoneyToElement(bean.getRebateMoney())+"元");
        viewHolder.tvDate.setText(bean.getInvestDate());
        return view;
    }

    static class ViewHolder {

        protected TextView tvName;
        protected TextView tvMoney;
        protected TextView tvRebateMoney;
        protected TextView tvDate;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            tvName = (TextView) rootView.findViewById(R.id.tv_name);
            tvMoney = (TextView) rootView.findViewById(R.id.tv_money);
            tvRebateMoney = (TextView) rootView.findViewById(R.id.tv_rebate_money);
            tvDate = (TextView) rootView.findViewById(R.id.tv_date);
        }
    }
}
